using System;
using System.Collections.Generic;
using System.Text;
using Web.Core.Providers;
using System.Collections;

namespace Web.Core.Objects
{
    public class Contacts
    {
        public static int InsertContact(Contact c)
        {
            return DataProvider.GetInstance().InsertDeleteUpdateContact(c, GlobalStorage.Action.Insert);
        }

        public static int DeleteContact(Contact c)
        {
            return DataProvider.GetInstance().InsertDeleteUpdateContact(c, GlobalStorage.Action.Delete);
        }

        public static int UpdateContact(Contact c)
        {
            return DataProvider.GetInstance().InsertDeleteUpdateContact(c, GlobalStorage.Action.Update);
        }

        public static ArrayList GetAllContactsByPage(int pageNum, int pageSize)
        {
            return DataProvider.GetInstance().GetContact(new Contact(0, "", "", "", "", ""), pageNum, pageSize);
        }

        public static int CountAllContact()
        {
            return DataProvider.GetInstance().CountContact(new Contact(0, "", "", "", "", ""));
        }

        public static Contact GetContactByID(int id)
        {
            ArrayList arr = DataProvider.GetInstance().GetContact(new Contact(id, "", "", "", "", ""), 1, 0);
            if (arr != null && arr.Count > 0)
                return arr[0] as Contact;
            return null;
        }
    }
}
